home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5363 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.2 KB

  1. Path: s3.phxslip4.indirect.com!pronet01
  2. From: pronet01@indirect.com (Mark Miller)
  3. Newsgroups: comp.lang.c++,comp.lang.c
  4. Subject: Re: Performance: C vs. C++
  5. Date: Sat, 3 Feb 1996 21:04:09 UNDEFINED
  6. Organization: Promark One
  7. Message-ID: <pronet01.31.003EB1E6@indirect.com>
  8. References: <30F6BAAC.12B5@iastate.edu> <4da9pn$a45@news.bridge.net> <4dnpl2$c8g@classic.iinet.com.au> <3105E9DC.1BE3@enermet.fi> <DLr46y.7rH@txnews.amd.com> <4elk5l$3f2q@yuma.ACNS.ColoState.EDU>
  9. NNTP-Posting-Host: s3.phxslip4.indirect.com
  10. X-Newsreader: Trumpet for Windows [Version 1.0 Rev B final beta #1]
  11.  
  12. In article <4elk5l$3f2q@yuma.ACNS.ColoState.EDU> steffend@lamar.colostate.edu (Dave Steffen) writes:
  13. >From: steffend@lamar.colostate.edu (Dave Steffen)
  14. >Subject: Re: Performance: C vs. C++
  15. >Date: 30 Jan 1996 17:23:01 GMT
  16.  
  17. >Bret Patterson (faustus) wrote: (in part)
  18.  
  19. >> The only thing of C++ that I know causes alot of overhead is
  20. >> exceptions. But other forms of error checking are available and
  21. >> exceptions can also be optimized/minimized.
  22.  
  23. >        I believe that exceptions only produce overhead _if_ an
  24. >exception is thrown; otherwise, there shouldn't be _any_ overhead.
  25.  
  26. >        At least, this is what Stoustrup says _should_ be the
  27. >case. Whether or not your compiler is up to the task is another
  28. >matter. ;-)
  29.  
  30. >                                 /\
  31. >                                 \/
  32.  
  33. >Dave Steffen                      No, his mind is not for rent
  34. >Dept. of Physics                  To any God or Government
  35. >Colorado State University         Always hopeful, yet discontent
  36. >steffend@lamar.colostate edu      He knows changes aren't permanent-
  37. >                                      But change is...
  38. >"Speak softly...                    
  39. >... and carry a black belt!"              -Neal Peart / RUSH
  40. >-----------------------------------------------------------------------
  41.  
  42. On the subject of performance, it irks me a little when I hear people say
  43. that they don't use C++ because it's "ALOT" slower than C when, in fact,
  44. (usually just with older compilers) you lose only about 5% and most often
  45. 0-5% (when you can upgrade your CPU).   To me (I can see the flame mail
  46. coming), I'd rather have a truely designed/implemented OO System (taking
  47. advantage of the OO features, identity/encapsulation/polymorphism-inheritant
  48. features) which will be a heck of alot more maintainable and less costly
  49. in the long run and spend about $1000 or less on a hardware boost...
  50.  
  51. 2 people told me in the past that C++ sucked because it was too slow and
  52. when I looked at their programs, I noticed that they did not pass by reference
  53. to methods (which always invokes constructors and destructors in addition
  54. to stack operations), and that they ended up calling member functions inside of
  55. for-loops;
  56.  
  57. for (int i = 0; i < object.size(); i++)
  58. without realizing 'object.size()' kept getting called during each iteration..
  59.  
  60. and little stuff like that...  Also, with proper use of 'inlining' with the 
  61. above techniques, there's no reason why a C++ system cannot run
  62. just as fast (maybe with milliseconds of difference when performing
  63. run-time identification) as a system written in C.  And look at the benefits
  64. you will get with an OO system...
  65.  
  66. theron kousek
  67.  
  68.  
  69.